import {reactive, ref} from "vue";

export function useMenus() {
    //收藏菜单
    const menus = reactive({
        appstore: {
            icon: 'chat-appstore',
            name: '全部收藏'
        },
        link: {
            icon: 'chat-link',
            name: '链接'
        },
        media: {
            icon: 'chat-image',
            name: '图片与视频'
        },
        note: {
            icon: 'chat-file-text',
            name: '笔记'
        },
        file: {
            icon: 'chat-folder-open',
            name: '文件'
        },
        chat: {
            icon: 'chat-message',
            name: '聊天记录'
        },
    });

    //当前选择的菜单
    let menuActive = ref('appstore');

    /**
     * 切换菜单
     * @param key
     */
    function switchMenu(key: string) {
        if (!menus.hasOwnProperty(key) || key === menuActive.value) {
            return;
        }
        menuActive.value = key;
    }

    return {menuActive, switchMenu, menus};
}